
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

now0=`date +'%H%M%S'`

# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"

# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
-Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseG1GC \
-XX:+PrintGCDateStamps \
-DIGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE=100 \
"

DRIVER_JVM_OPTS=${DRIVER_JVM_OPTS}"-Xmx1024m"

SERVER_JVM_OPTS=${SERVER_JVM_OPTS}"-Xms8g -Xmx8g"

#Ignite version
ver="RELEASE-"

# List of default probes.
# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux).
BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe

# Packages where the specified benchmark is searched by reflection mechanism.
BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick

# Flag which indicates to restart the servers before every benchmark execution.
RESTART_SERVERS=true

# Probe point writer class name.
# BENCHMARK_WRITER=

# The benchmark is applicable only for 1 server and 1 driver
SERVER_HOSTS=127.0.0.1
DRIVER_HOSTS=127.0.0.1

# Remote username.
# REMOTE_USER=

# Number of nodes, used to wait for the specified number of nodes to start.
nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))

# Backups count.
b=0

# Warmup.
w=30

# Duration.
d=200

# Threads count.
t=4

# Sync mode.
sm=PRIMARY_SYNC

# Jobs.
j=10

# Parameters that should be the same across all the benchmarks launches.
commonParams="\
-cfg ${SCRIPT_DIR}/../config/ignite-localhost-pagereplacement-config.xml -nn ${nodesNum} -sn IgniteNode \
-b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -cwd -cl\
"

# With page replacement.
repl="-DREPLACE_RATIO=2.0"

# Without page replacement.
norepl="-DREPLACE_RATIO=0.5"

# Page replacement modes.
rlru="-SIGNITE_PAGE_REPLACEMENT_MODE=RANDOM_LRU"
slru="-SIGNITE_PAGE_REPLACEMENT_MODE=SEGMENTED_LRU"
clck="-SIGNITE_PAGE_REPLACEMENT_MODE=CLOCK"

# Benchmark operations.
putBenchmark="-dn IgnitePutWithPageReplacementBenchmark"
getBenchmark="-dn IgniteGetWithPageReplacementBenchmark"

# Benchmark with background scans.
bgScan="-DBACKGROUND_SCAN_INTERVAL=10000"

# Run configuration which contains all benchmarks.
CONFIGS="\
${commonParams} ${norepl} ${rlru} ${putBenchmark} -ds ${ver}cache-put-no-pagereplacement-RLRU,\
${commonParams} ${norepl} ${slru} ${putBenchmark} -ds ${ver}cache-put-no-pagereplacement-SLRU,\
${commonParams} ${norepl} ${clck} ${putBenchmark} -ds ${ver}cache-put-no-pagereplacement-CLCK,\
${commonParams} ${repl} ${rlru} ${putBenchmark} -ds ${ver}cache-put-pagereplacement-RLRU,\
${commonParams} ${repl} ${slru} ${putBenchmark} -ds ${ver}cache-put-pagereplacement-SLRU,\
${commonParams} ${repl} ${clck} ${putBenchmark} -ds ${ver}cache-put-pagereplacement-CLCK,\
${commonParams} ${repl} ${rlru} ${putBenchmark} ${bgScan} -ds ${ver}cache-put-pagereplacement-RLRU-BG,\
${commonParams} ${repl} ${slru} ${putBenchmark} ${bgScan} -ds ${ver}cache-put-pagereplacement-SLRU-BG,\
${commonParams} ${repl} ${clck} ${putBenchmark} ${bgScan} -ds ${ver}cache-put-pagereplacement-CLCK-BG,\
${commonParams} ${norepl} ${rlru} ${getBenchmark} -ds ${ver}cache-get-no-pagereplacement-RLRU,\
${commonParams} ${norepl} ${slru} ${getBenchmark} -ds ${ver}cache-get-no-pagereplacement-SLRU,\
${commonParams} ${norepl} ${clck} ${getBenchmark} -ds ${ver}cache-get-no-pagereplacement-CLCK,\
${commonParams} ${repl} ${rlru} ${getBenchmark} -ds ${ver}cache-get-pagereplacement-RLRU,\
${commonParams} ${repl} ${slru} ${getBenchmark} -ds ${ver}cache-get-pagereplacement-SLRU,\
${commonParams} ${repl} ${clck} ${getBenchmark} -ds ${ver}cache-get-pagereplacement-CLCK,\
${commonParams} ${repl} ${rlru} ${getBenchmark} ${bgScan} -ds ${ver}cache-get-pagereplacement-RLRU-BG,\
${commonParams} ${repl} ${slru} ${getBenchmark} ${bgScan} -ds ${ver}cache-get-pagereplacement-SLRU-BG,\
${commonParams} ${repl} ${clck} ${getBenchmark} ${bgScan} -ds ${ver}cache-get-pagereplacement-CLCK-BG,\
"
